<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    a {
      text-decoration: none;
    }

    li {
      list-style: none;
    }

    body {
      background-color: #f4f4f4;
    }

    .wrapper {
      width: 1190px;
      margin: 0 auto;
      overflow: hidden;
    }

    .list {
      display: flex;
      flex-wrap: wrap;
      width: 1200px;
    }

    .list li {
      width: 230px;
      background: #fff;
      margin: 0 10px 10px 0;
      padding: 10px;
      box-sizing: border-box;
      position: relative;
    }

    .list li .shadow {
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.5);
      display: none;
    }

    .list li .shadow span {
      position: absolute;
      right: 10px;
      top: 10px;
      color: #fff;
      cursor: pointer;
    }

    .list li .shadow a {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 20px;
      margin: auto;

      background-color: #fff;
      border-radius: 20px;
      height: 30px;
      line-height: 30px;
      width: 100px;
      text-align: center;
      color: #000;
    }

    .list li.on .shadow {
      display: block;
    }
    .list{
      display: none;
    }
    .list.on{
      display: flex;
    }
  </style>
</head>

<body>
  <div id="app">
    <div class="wrapper">
      <ul class="list"  v-for="(item , index) in list" :key="index" :class="{on:(iNow === index)}">
        <li v-for="(itm , ind) in item.content" :key="itm.goods_id" >
          <a  href="javascript:;">
            <img width="120" :src="itm.img_big_logo" alt="">
            <p>{{itm.title}}</p>
            <b><i>￥</i>{{itm.current_price}}</b>
          </a>
          <div class="shadow">
            <span>×</span>
            <a href="javascript:">找相似</a>
          </div>
        </li>
      </ul>
    </div>
    <div class="page">
      <div class="btn">
        <span @click="iNow = index" :class="{active:(iNow === index)}" v-for="(item,index) in list">{{item.page}}</span>
        <button @click="prev()">上一页</button><button @click="next()">下一页</button><i>当前页</i><input type="text" v-model.number="nowpage">
      </div>
    </div>
  </div>
  <script src="axios.js"></script>
  <script src="lib/Vue2.js"></script>
  <script>
    const API = 'http://localhost:8888'
    new Vue({
      el: '#app',
      data() {
        return {
          iNow: 0,
          list: [
            {
              page: 1,
              content: ''
            },
            {
              page: 2,
              content: ''
            },
            {
              page: 3,
              content: ''
            },
            {
              page: 4,
              content: ''
            },
            {
              page: 5,
              content: ''
            }
          ]
        }
      },
      mounted() {
        const API = 'http://localhost:8888'
        axios({
          url: API + '/goods/list?pagesize=75',
          methods: 'get'
        }).then(res => {
          res.data.list.map((item, index) => {
            let res2 = res.data.list.splice(0, 15)
            this.list[index].content = res2
          })

        })
      },
      methods: {
        prev() {
          this.iNow--
          if (this.iNow <= -1) {
            this.iNow = 0
          }
        },
        next() {
          this.iNow++
          if (this.iNow >= 5) {
            this.iNow = 4
          }
        }
      },
      computed: {
        nowpage: {
          get() {
            return this.iNow + 1
          },
          set(val) {
            this.iNow = val - 1
          }
        }
      }
    })

  </script>
</body>

</html>